<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
     * {
         margin: 0;
         padding: 0;
     }   
    div {
        width: 200px;
        height: 150px;
        background-color: green;
        float: left;
        margin-left: 10px;
    }
    </style>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <script>
     var divList =  document.getElementsByTagName("div");
     //注册鼠标进入离开事件
     for (const divObjet of divList) {
        //鼠标进入事件
        divObjet.onmouseover = function (){
            this.style.border = "2px solid  red"
        }
        //鼠标离开事件
        divObjet.onmouseout = function (){
            this.style.border = ""
        }
     }
    </script>
</body>
</html>